/*  
 * 文件名：UserContext.java
 * 版权：<版权>
 * 描述：<描述>
 * 修改人：<修改人>
 * 修改时间：2017年6月29日
 * 修改单号：<修改单号>
 * 修改内容：<修改内容>
 * 
 */
package com.zzw.spring;

import java.util.Map;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;
import com.zzw.annotion.Cache;

/**
 * [一句话功能描述]
 * [详细功能描述]
 * @version [版本号 日期]
 * @author Administrator
 * @since <起始版本>
 *
 */
@Component
public class UserContext implements ApplicationContextAware,ApplicationListener<ContextRefreshedEvent>
{

    private ApplicationContext context;
    private Map<String, Object> map;
    
    public void onApplicationEvent(ContextRefreshedEvent event)
    {
        map = context.getBeansWithAnnotation(Cache.class);
        /*for(Entry<String, Object> entry:map.entrySet()){
            System.out.println(entry.getKey() + "***" + entry.getValue());
            UserServiceImpl user = (UserServiceImpl) entry.getValue();
            user.add();
        }*/
        
    }

    public void setApplicationContext(ApplicationContext context) throws BeansException
    {
        this.context = context;
    }

    public ApplicationContext getContext()
    {
        return context;
    }

    public void setContext(ApplicationContext context)
    {
        this.context = context;
    }

    public Map<String, Object> getMap()
    {
        return map;
    }

    public void setMap(Map<String, Object> map)
    {
        this.map = map;
    }
    
}
